package org.example.cloudindex.web.fegin;

import org.example.damai.entiy.User;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

// feign定义服务必须是全局唯一
@FeignClient(value = "cloud-order",
        fallback = OrderDoImpl.class)
public interface OrderDo {

    @RequestMapping("order")
    public String order();

    @RequestMapping("feign/hello")
    public String hello(@RequestParam("name") String name);

    @RequestMapping("feign/add")
    public int add(@RequestParam("a") int a,
                   @RequestParam("b")int b);

    @RequestMapping("feign/sub/{a}/{b}")
    public int sub(@PathVariable("a") int a,
                   @PathVariable("b")int b);

    @RequestMapping("feign/setUser")
    public User setUser(@RequestParam("newName")String newName,
                        @RequestParam("newAge")Integer newAge,
                        @RequestBody User user);
}
